$(function () {
    $("#sendMsgCode").on('click',function(){
        var mobile = $("#mobile_value").val();
        if(mobile==null || mobile==""){
            return false;
        }
        $.ajax({
            url : "/check/mobile",
            type : "POST",
            async:false,
            data : {mobile:mobile},
            dataType : "json",
            success : function(data) {
                if(!data){
                    layer.msg("短信发送失败,请重新再试！");
                }
            }
        });
    });
});


function changedata(otype,othis){
    var parentId = $(othis).val();
    $.ajax({
        url : "/ajaxAdd",
        type : "POST",
        async:false,
        data : {otype:otype,parentId:parentId},
        dataType : "json",
        success : function(data) {
            $.each(data,function(key,values){
                console.log(key);
                if(key=="city"){
                    var cityObj = $("#o_city");
                    cityObj.empty();
                    var cityHtml = "";
                    $(values).each(function(index,item){
                        var dataObj = JSON.stringify(item);
                        var jsonObject = JSON.parse(dataObj);
                        cityHtml += "<option value='"+jsonObject.id+"'>";
                        cityHtml += jsonObject.name;
                        cityHtml += "</option>";
                        console.log("index"+index+"item"+jsonObject);
                    });
                    console.log("cityHtml"+cityHtml);
                    cityObj.html(cityHtml);
                }else if(key="location"){
                    var locationObj = $("#o_location");
                    locationObj.empty();
                    var locationHtml = "";
                    $(values).each(function(index,item){
                        var dataObj = JSON.stringify(item);
                        var jsonObject = JSON.parse(dataObj);
                        locationHtml += "<option value='"+jsonObject.id+"'>";
                        locationHtml += jsonObject.name;
                        locationHtml += "</option>";
                        console.log("index"+index+"item"+dataObj);
                    });
                    locationObj.html(locationHtml);
                }
            });
        }
    });
}